using System;
using UnityEngine;
using UnityEngine.EventSystems;

namespace Game.Framework.UI
{
    public class MonoHandler : MonoBehaviour,IBeginDragHandler,IEndDragHandler
        ,IPointerDownHandler,IPointerUpHandler,IDragHandler
    {
        public Action<PointerEventData> OnBeginDragDelegate;
        public Action<PointerEventData> OnEndDragDelegate;
        public Action<PointerEventData> OnDragDelegate;
        public Action<PointerEventData> OnPointerDownDelegate;
        public Action<PointerEventData> OnPointerUpDelegate;

        public Action UpdateDelegate;

        public void OnBeginDrag(PointerEventData eventData)
        {
            OnBeginDragDelegate?.Invoke(eventData);
        }

        public void OnEndDrag(PointerEventData eventData)
        {
            OnEndDragDelegate?.Invoke(eventData);
        }

        public void OnPointerDown(PointerEventData eventData)
        {
            OnPointerDownDelegate?.Invoke(eventData);
        }

        public void OnPointerUp(PointerEventData eventData)
        {
            OnPointerUpDelegate?.Invoke(eventData);
        }
        
        private void Update()
        {
            UpdateDelegate?.Invoke();
        }

        public void OnDrag(PointerEventData eventData)
        {
            OnDragDelegate?.Invoke(eventData);
        }
    }
}